load("@rules_cc//cc:defs.bzl", "cc_binary")
load("//bzl:cpp_library.bzl", "cpp_library")
load("//bzl:cpp_unittest.bzl", "cpp_unittest")

package(default_visibility = ["//visibility:public"])

cpp_unittest(
    name = "compression_test",
    size = "enormous",
    srcs = ["CompressionTest.cpp"],
    deps = [
        "//folly:random",
        "//folly:varint",
        "//folly/compression",
        "//folly/hash",
        "//folly/io:iobuf",
        "//folly/portability:gtest",
        "@glog",
        "@zstd",
    ],
)

# TODO(kgk): Fix test.
# cpp_unittest(
#     name = "compression_context_pool_test",
#     srcs = [
#         "CompressionContextPoolTest.cpp",
#     ],
#     deps = [
#         "//folly/compression:compression_context_pool",
#         "//folly/compression:compression_context_pool_singletons",
#         "//folly/portability:gtest",
#     ],
# )

cc_binary(
    name = "quotient_multiset_benchmark",
    srcs = [
        "QuotientMultiSetBenchmark.cpp",
    ],
    deps = [
        "//folly:benchmark",
        "//folly:format",
        "//folly:random",
        "//folly:string",
        "//folly/compression:quotient_multiset",
        "//folly/compression/elias_fano:elias_fano_coding",
        "//folly/container:enumerate",
        "//folly/container:f14_hash",
        "//folly/container:foreach",
        "//folly/experimental/test:coding_test_utils",
        "//folly/init",
        "@boost.sort",
    ],
)

cpp_unittest(
    name = "quotient_multiset_test",
    srcs = [
        "QuotientMultiSetTest.cpp",
    ],
    deps = [
        "//folly:format",
        "//folly:random",
        "//folly/compression:quotient_multiset",
        "//folly/container:enumerate",
        "//folly/io:iobuf",
        "//folly/portability:gtest",
    ],
)

cpp_unittest(
    name = "instructions_test",
    srcs = ["InstructionsTest.cpp"],
    target_compatible_with = select({
        # TODO: fails on Mac.
        "@platforms//os:macos": ["@platforms//:incompatible"],
        "//conditions:default": [],
    }),
    deps = [
        "//folly/compression:instructions",
        "//folly/portability:gtest",
        "@glog",
    ],
)

cpp_unittest(
    name = "select64_test",
    srcs = ["Select64Test.cpp"],
    deps = [
        "//folly/compression:instructions",
        "//folly/compression:select64",
        "//folly/portability:gtest",
    ],
)

cpp_library(
    name = "coding_test_utils",
    srcs = ["CodingTestUtils.cpp"],
    hdrs = ["CodingTestUtils.h"],
    deps = [
        "//folly:benchmark",
        "//folly:likely",
        "//folly:optional",
        "//folly/compression:instructions",
        "//folly/portability:gflags",
        "//folly/portability:gtest",
        "@glog",
    ],
)
